package com.ruoyi.web.controller.jiugongge;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jiugongge.domain.JiugonggeRegistration;
import com.ruoyi.jiugongge.service.IJiugonggeRegistrationService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.base.AjaxResult;

/**
 * 九宫格参与人员 信息操作处理
 * 
 * @author lzy
 * @date 2019-01-24
 */
@Controller
@RequestMapping("/jiugongge/jiugonggeRegistration")
public class JiugonggeRegistrationController extends BaseController
{
    private String prefix = "jiugongge/jiugonggeRegistration";
	
	@Autowired
	private IJiugonggeRegistrationService jiugonggeRegistrationService;
	
	@RequiresPermissions("jiugongge:jiugonggeRegistration:view")
	@GetMapping()
	public String jiugonggeRegistration()
	{
	    return prefix + "/jiugonggeRegistration";
	}
	
	/**
	 * 查询九宫格参与人员列表
	 */
	@RequiresPermissions("jiugongge:jiugonggeRegistration:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(JiugonggeRegistration jiugonggeRegistration)
	{
		startPage();
        List<JiugonggeRegistration> list = jiugonggeRegistrationService.selectJiugonggeRegistrationList(jiugonggeRegistration);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出九宫格参与人员列表
	 */
	@RequiresPermissions("jiugongge:jiugonggeRegistration:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiugonggeRegistration jiugonggeRegistration)
    {
    	List<JiugonggeRegistration> list = jiugonggeRegistrationService.selectJiugonggeRegistrationList(jiugonggeRegistration);
        ExcelUtil<JiugonggeRegistration> util = new ExcelUtil<JiugonggeRegistration>(JiugonggeRegistration.class);
        return util.exportExcel(list, "jiugonggeRegistration");
    }
	
	/**
	 * 新增九宫格参与人员
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存九宫格参与人员
	 */
	@RequiresPermissions("jiugongge:jiugonggeRegistration:add")
	@Log(title = "九宫格参与人员", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(JiugonggeRegistration jiugonggeRegistration)
	{		
		return toAjax(jiugonggeRegistrationService.insertJiugonggeRegistration(jiugonggeRegistration));
	}

	/**
	 * 修改九宫格参与人员
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		JiugonggeRegistration jiugonggeRegistration = jiugonggeRegistrationService.selectJiugonggeRegistrationById(id);
		mmap.put("jiugonggeRegistration", jiugonggeRegistration);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存九宫格参与人员
	 */
	@RequiresPermissions("jiugongge:jiugonggeRegistration:edit")
	@Log(title = "九宫格参与人员", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(JiugonggeRegistration jiugonggeRegistration)
	{		
		return toAjax(jiugonggeRegistrationService.updateJiugonggeRegistration(jiugonggeRegistration));
	}
	
	/**
	 * 删除九宫格参与人员
	 */
	@RequiresPermissions("jiugongge:jiugonggeRegistration:remove")
	@Log(title = "九宫格参与人员", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(jiugonggeRegistrationService.deleteJiugonggeRegistrationByIds(ids));
	}
	
}
